#include "stdafx.h"
#include "HiPerfTimer.h"


CHiPerfTimer::CHiPerfTimer(void)
{
	ZeroMemory(&startTime, sizeof(LARGE_INTEGER));
	ZeroMemory(&stopTime, sizeof(LARGE_INTEGER));

	LARGE_INTEGER freq;
	if (QueryPerformanceFrequency(&freq) == FALSE)
	{
		printf("Can not query the CPU frequency!\n");
	}
	PCFreq = double(freq.QuadPart)/1000.0;
}


CHiPerfTimer::~CHiPerfTimer(void)
{
}


void CHiPerfTimer::Start()
{
	QueryPerformanceCounter(&startTime);
}

void CHiPerfTimer::Stop()
{
	QueryPerformanceCounter(&stopTime);
}

double CHiPerfTimer::GetDuration()
{
	return double(stopTime.QuadPart - startTime.QuadPart)/PCFreq;
}